package com.rec.repository;


import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.rec.entity.Students;

public interface StudentRepository extends JpaRepository<Students, Integer>,
JpaSpecificationExecutor<Students> {
	@Modifying
	@Query(value="update students s set s.name = :name,s.sex = :sex,s.memberid =:memberid,s.status= :status where s.id = :id",nativeQuery = true)
	Integer updateStu(@Param("id")Integer id, 
			@Param("name")String name,
			@Param("sex")String sex, 
			@Param("memberid")Integer memberid, 
			@Param("status")Integer status);
	@Modifying
	@Query(value="delete from students where id = :id ",nativeQuery = true)
	Integer deleteStu(@Param("id")Integer id);
	
	@Query(value="select * from students s where s.cardno = :cardno",nativeQuery = true)
	Students findByCardno(@Param("cardno")String cardno);
	
	@Modifying
	@Query(value="update students s set s.status = :id where s.cardno = :cardno ",nativeQuery = true)
	Integer updateStatus(@Param("cardno")String cardno, @Param("id")Integer id);
		
}
